package ro.imc.app.wifi;


import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.widget.Button;

public class MenuActivity extends Activity {
	
	private Button btnLogin, btnRegister, btnLoginConnect;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_menu);
		
		popLogin();
		popRegister();
	}
	
	
	private void popLogin(){
		btnLogin = (Button)findViewById(R.id.login);
		
		btnLogin.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				AlertDialog.Builder builder = new AlertDialog.Builder(MenuActivity.this);
				builder.setTitle("Wifi Passw - Sign In");
				
				LayoutInflater inflater = MenuActivity.this.getLayoutInflater();
				builder.setView(inflater.inflate(R.layout.login_page_layout, null))
				
				.setPositiveButton("Sign In",new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog,int id) {
						// if this button is clicked, close
						// current activity
						MenuActivity.this.finish();
						Intent intent = new Intent(getApplicationContext(), WelcomeActivity.class);
						startActivity(intent);
					}
				  })
				  
				.setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog,int id) {
						// if this button is clicked, just close
						// the dialog box and do nothing
						dialog.cancel();
					}
				});
				
				AlertDialog alertDialog = builder.create();
				 
				// show it
				alertDialog.show();
			
			}
			
		});
		
		
		
	}
	
	
	private void popRegister(){
		btnRegister = (Button)findViewById(R.id.register);
		btnRegister.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				AlertDialog.Builder builder = new AlertDialog.Builder(MenuActivity.this);
				builder.setTitle("Wifi Passw - Sign Up");
				
				LayoutInflater inflater = MenuActivity.this.getLayoutInflater();
				builder.setView(inflater.inflate(R.layout.register_page_layout, null))
				.setPositiveButton("Sign Up",new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog,int id) {
						// if this button is clicked, close
						// current activity
						MenuActivity.this.finish();
					}
				  })
				  
				.setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog,int id) {
						// if this button is clicked, just close
						// the dialog box and do nothing
						dialog.cancel();
					}
				});
				
				AlertDialog alertDialog = builder.create();
				 
				// show it
				alertDialog.show();
			
			}
			
		});
	}
	
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.menu, menu);
		return true;
	}

}
